package gac.helloworld;

import android.text.format.Time;

public class AlarmData {

	public static final int AM = 0;
	public static final int PM = 1;
	public static final int NO_WARN_TIME = -1;
	
    private String mDestination;
    private int mHour;
    private int mMinute;
    private int mAMPM;
    private int mWarnTime;
    private long mId;
    
    // am and pm must be 1 or 0. behavior is undefined otherwise.
    public AlarmData(long id, String destination, int hour, int min, int ampm,
    		int warnTime) {
    	mDestination = destination;
    	mHour = hour;
    	mMinute = min;
    	mAMPM = ampm;
    	mWarnTime = warnTime;
    	mId = id;
    } 
    
    public long getId() {
    	return mId;
    }
    
    public String toString() {
    	return "Alarm for " + mDestination;
    }
    
    public AlarmData() { }
    
    public String getDestination() {
        return mDestination;
    }
    public void setDestination(String destination) {
        mDestination = destination;
    }
    
    public int getAlarmHour() {
        return mHour;
    }
    public void setAlarmHour(int hour) {
        mHour = hour;
    }	
    
    public int getAlarmMin() {
        return mMinute;
    }
    public void setAlarmMin(int min) {
        mMinute = min;
    }	
    
    public int getAMPM() {
        return mAMPM;
    }
    public void setAMPM(int ampm) {
        mAMPM = ampm;
    }	
    
    public int getWarnTime(){
    	return mWarnTime;
    }
    
    public void setWarnTime(int warnTime){
    	mWarnTime = warnTime;
    }

    public String pad(int padMe)
    {
    	if (padMe < 10)
    		return "0" + padMe; 
    	else
    		return "" + padMe;
    }
    
    public static String getAMPMString(int ampm)
    {
    	return ampm == 0 ? "AM" : "PM";
    }
    
	public String getArrivalTimeString() {
		// TODO Auto-generated method stub
		String ampmStr = AlarmData.getAMPMString(mAMPM);
		return pad(mHour) + ":" + pad(mMinute);//+ " " + ampmStr; /* not doing am/pm atm */
	}	 
	
	public String getAlarmTimeString() {
		if (mWarnTime == NO_WARN_TIME)
				return "unspecified";
		else{
			return MapHandlerActivity.timeUntilAlarm(mDestination, mHour*3600+mMinute*60, mWarnTime*60);
		}
	}	 
	
}
